import request from './request'

export function query ({currentPage = 1, perPage = 10, ruleActivityId, ruleActivityShortname} = {}) {
  return request({
    url: '/activity/list.do',
    method: 'GET',
    params: {currentPage, perPage, ruleActivityId, ruleActivityShortname}
  })
}

export function create ({ruleActivityShortname, ruleBrhId, activityStartTime, activityEndTime, validDate, bonusType, cyclePoints, ruleActivityDesc, crtId, channel = 'ebj'}) {
  return request({
    url: '/activity/add.do',
    method: 'POST',
    body: {ruleActivityShortname, ruleBrhId, activityStartTime, activityEndTime, validDate, bonusType, cyclePoints, ruleActivityDesc, crtId, channel}
  })
}

export function edit ({id, ruleActivityShortname, ruleBrhId, activityStartTime, activityEndTime, validDate, bonusType, cyclePoints, ruleActivityDesc, updId, channel = 'ebj'}) {
  return request({
    url: '/activity/modify.do',
    method: 'POST',
    body: {id, ruleActivityShortname, ruleBrhId, activityStartTime, activityEndTime, validDate, bonusType, cyclePoints, ruleActivityDesc, updId, channel}
  })
}

export function del (id) {
  return request({
    url: '/activity/delete.do',
    method: 'POST',
    body: {id}
  })
}

export function queryChild (activeId) {
  return request({
    url: '/ruleInf/list.do',
    method: 'GET',
    params: {activeId}
  })
}

export function checkChild ({activeId, ruleId = undefined} = {}) {
  return request({
    url: '/ruleInf/getInfo.do',
    method: 'GET',
    params: {activeId, ruleId}
  })
}

export function queryList () {
  return request({
    url: '/roleParam/queryAllWhthParamProp.do',
    method: 'GET',
    params: {}
  })
}

export function createChild ({ruleGroupId, ruleDesc, rulePriority, ruleStatus, activeId, ruleType, remark, fieldValue = 'txn_amt', expColumn1, expColumn2, expColumn3, expColumn4, expColumn5}) {
  return request({
    url: '/ruleInf/add.do',
    method: 'POST',
    body: {ruleGroupId, ruleDesc, rulePriority, ruleStatus, activeId, ruleType, remark, fieldValue, expColumn1, expColumn2, expColumn3, expColumn4, expColumn5}
  })
}

export function editChild ({ruleGroupId, ruleDesc, rulePriority, ruleStatus, activeId, ruleType, remark, fieldValue, expColumn1, expColumn2, expColumn3, expColumn4, expColumn5, id, ruleId}) {
  return request({
    url: '/ruleInf/modify.do',
    method: 'POST',
    body: {ruleGroupId, ruleDesc, rulePriority, ruleStatus, activeId, ruleType, remark, fieldValue, expColumn1, expColumn2, expColumn3, expColumn4, expColumn5, id, ruleId}
  })
}

export function delChild (ruleId) {
  return request({
    url: '/ruleInf/delete.do',
    method: 'POST',
    body: {ruleId}
  })
}

export function submit (activeId) {
  return request({
    url: '/activity/submit.do',
    method: 'POST',
    body: {activeId}
  })
}

export function aduit ({id, ruleActivityStatus}) {
  return request({
    url: '/activity/aduit.do',
    method: 'POST',
    body: {id, ruleActivityStatus}
  })
}

export function queryRuleGroups (ruleActivityId) {
  return request({
    url: '/activity/queryRuleGroup.do',
    method: 'GET',
    params: {ruleActivityId}
  })
}
